#!/bin/bash

echo "=== 交互式会话Bug测试 ==="

# Create a test script for single interactive session
cat > /tmp/interactive_bug_test_commands << 'EOF'
SHOW DATABASES;
SHOW TABLES;
CREATE DATABASE bugtest;
USE bugtest;
SHOW TABLES;
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(50));
DESCRIBE users;
DROP TABLE users;
CREATE TABLE users (id INT PRIMARY KEY, email VARCHAR(100));
DESCRIBE users;
CREATE TABLE test_dup (id INT, id INT, name VARCHAR(50));
DESCRIBE test_dup;
CREATE TABLE pk_test (id INT PRIMARY KEY, value VARCHAR(50));
INSERT INTO pk_test VALUES (1, 'first');
INSERT INTO pk_test VALUES (1, 'duplicate');
SELECT * FROM pk_test;
UPDATE pk_test SET value = 'updated' WHERE id = 1;
SELECT * FROM pk_test;
quit
EOF

echo "在单个交互式会话中运行所有命令："
echo "---"
cat /tmp/interactive_bug_test_commands
echo "---"

# Run all commands in a single interactive session
./bin/gu_new -h localhost -P 7777 -u admin -i < /tmp/interactive_bug_test_commands

# Cleanup
rm -f /tmp/interactive_bug_test_commands

echo "=== 交互式会话Bug测试完成 ==="